package com.swk.common.config;

import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

@ComponentScan
@Configuration
public class MyBatisScannerConfig {
    @Autowired
    private Environment env;

    @Bean
    public MapperScannerConfigurer MapperScannerConfigurer() {
        MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();
//        System.out.println("env======" +env.getProperty("mybatis.scanner.basePackage"));
//        mapperScannerConfigurer.setBasePackage(env.getProperty("mybatis.scanner.basePackage"));        System.out.println("env======" +env.getProperty("mybatis.scanner.basePackage"));
        mapperScannerConfigurer.setBasePackage("com.swk.*.dao");
        mapperScannerConfigurer.setSqlSessionFactoryBeanName("sqlSessionFactory");
        return mapperScannerConfigurer;
    }
}
